﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace BanHangCshap.Class
{
    class ChucNang:Database
    {
        private string _macn;
        public string macn
        {
            get
            {
                return _macn;
            }
            set
            {
                _macn = value;
            }
        }
        private string _tencn;
        public string tencn
        {
            get
            {
                return _tencn;
            }
            set
            {
                _tencn = value;
            }
        }
        private string _manhomcn;
        public string manhomcn
        {
            get
            {
                return _manhomcn;
            }
            set
            {
                _manhomcn = value;
            }
        }
        public Boolean themChucNang()
        {
            string sql = "insert into ChucNang(macn,tencn,manhomcn) values ('" + macn + "',N'" + tencn + "','" + manhomcn + "')";
            return executeQuery(sql);
        }
        public Boolean xoaChucNang(string macn)
        {
            string sql = "delete ChucNang where macn = '" + macn + "'";
            return executeQuery(sql);
        }
        public DataTable layDSChucNang()
        {
            string sql = "select distinct chon,a.manhomcn,tennhomcn,b.macn,tencn  ";
            sql += "from NhomChucNang a left join ChucNang b on  a.manhomcn = b.manhomcn order by manhomcn ";
            return getDataTable(sql);
        }

    }
}
